using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Preferences;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using TheNorthStar.Api.Requests;

namespace NorthStar.Passenger
{
    [Activity(Label = "Rate Driver")]
    public class RateDriverActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.RateMyDriverLayout);

            Button positiveRateDriverBtn = FindViewById<Button>(Resource.Id.positiveRateDriverBtn);
            Button negativeRateDriverBtn = FindViewById<Button>(Resource.Id.negativeRateDriverBtn);

          

            positiveRateDriverBtn.Click += (sender, e) =>
                                               {
                                                   RateDriver(true);
                                               };

            negativeRateDriverBtn.Click += (sender, e) =>
                                               {
                                                   RateDriver(false);
                                               };

        }

        private void RateDriver(bool rating)
        {
            int bookingId = Intent.GetIntExtra("refId", 0);

            RateDriverRequest request = new RateDriverRequest();
            request.IMEI = Helper.GetDeviceId(ApplicationContext);
            request.PhoneNumber = Helper.GetPhoneNumber(ApplicationContext);
            request.BookingId = bookingId;
            request.driverRating = rating;

            RateDriverAsync async = new RateDriverAsync(this,request);
            async.Execute();
            
            //setup to show the confirmation screen
            Intent a = new Intent(this, typeof(HomeActivity));
            a.AddFlags(ActivityFlags.ClearTop);
            a.PutExtra("source", "driverRating");
            StartActivity(a);
        }
    }
}